
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Unocss from 'unocss/vite'
import {
  presetAttributify,
  presetIcons,
  presetUno,
  transformerDirectives,
  transformerVariantGroup,
} from 'unocss'
// https://vitejs.dev/config/
export default defineConfig({
  server: {
    host: "0.0.0.0", //解决 vite use--host to expose
    port: 8080, //配置端口
    open: true, //配置默认打开浏览器
    // 本地跨域代理
    proxy: {
      // '/api': {
      //   target: 'https://adminsystes.dev.dclovemx.top',
      //   changeOrigin: true
      // },
      // '/v1': {
      //   target: 'https://adminsystes.dev.dclovemx.top',
      //   changeOrigin: true
      // },
      //  '/file': {
      //   target: 'https://adminsystes.dev.dclovemx.top',
      //   changeOrigin: true
      // },
      '/api': {
        target: 'http://192.168.86.9:8888',
        changeOrigin: true
      },
      '/v1': {
        target: 'http://192.168.86.9:8888',
        changeOrigin: true
      },
      '/file': {
        target: 'http://192.168.86.9:8889',
        changeOrigin: true
      },
    }
  },
  plugins: [
    vue(),
    Components({
      // allow auto load markdown components under `./src/components/`
      extensions: ['vue', 'md'],
      // allow auto import and register components used in markdown
      include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
      resolvers: [
        ElementPlusResolver({
          importStyle: 'sass',
        }),
      ],
      dts: 'src/components.d.ts',
    }),

    // https://github.com/antfu/unocss
    // see unocss.config.ts for config
    Unocss({
      presets: [
        presetUno(),
        presetAttributify(),
        presetIcons({
          scale: 1.2,
          warn: true,
        }),
      ],
      transformers: [
        transformerDirectives(),
        transformerVariantGroup(),
      ]
    }),
  ],
  // base: "./",
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    },
  },
})

